import { ShopTwoTone } from '@ant-design/icons';
import { Avatar } from 'antd';

const icons = import.meta.glob('./icons/*.svg', {
  eager: true,
});

const iconsMap = Object.keys(icons).reduce((map, imagePath) => {
  const imageName = imagePath
    .split('/')
    .pop()
    .replace(/\.\w+$/, '');
  map[imageName] = icons[imagePath].default;
  return map;
}, {});

/**
 * -1: zjfsc(找家纺商城)
    0: 线下店铺
    1: jd(京东)
    2: sn(苏宁)
    3: suning-lt(苏宁特卖)
    4: 1688(阿里巴巴)
    5: wph(唯品会)
    6: youzan(有赞)
    7: beibei(贝贝)
    8: taobao(淘宝)
    9: pdd(拼多多)
    10: hqbs(环球捕手)
    11: yunji(云集)
    12: ks(快手)
    13: qimen(奇门)
    14: (zjfscht)找家纺商城后台
    15: dy(抖音)
    16: wph_jtx(唯品会jitx)
    17: dy_df(抖音代发)
    18: tm(天猫)
    19: jd_yc(京东云仓)
    20: jst(聚水潭)
    21: tm_sales(天猫供销);
 */
function ShopIcons(props) {
  const { type } = props;

  return <Avatar size={20} src={iconsMap[type] ? <img src={iconsMap[type]} alt="avatar" /> : <ShopTwoTone />} />;
}

export default ShopIcons;
